import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class FloorContent extends StatelessWidget {
  final Map floorData;
  const FloorContent({ Key key, this.floorData }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Column(
      children: <Widget>[
        FloorTitle(pictureAddress: floorData['titlePic']),
        Padding(
          padding: EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(20)),
          child: Column(
            children: <Widget>[
              FirstRow(goodsList: floorData['list']),
              SecondRow(goodsList: floorData['list']),
            ]
          ),
        )
      ]
    );
  }
}

class FloorTitle extends StatelessWidget {
  final String pictureAddress;
  const FloorTitle({ Key key, this.pictureAddress }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: EdgeInsets.all(ScreenUtil().setWidth(20)),
      child: Image(image: AssetImage(pictureAddress)),
    );
  }
}

class FirstRow extends StatelessWidget {
  final List goodsList;
  const FirstRow({ Key key, this.goodsList }) : super(key: key);


  @override
  Widget build(BuildContext context) {
    return Row(
      children: <Widget>[
        GetGoodsItem(item: this.goodsList[0]),
        Column(
          children: <Widget>[
            GetGoodsItem(item: this.goodsList[1]),
            GetGoodsItem(item: this.goodsList[2]),
          ]
        )
      ],
    );
  }
}

class SecondRow extends StatelessWidget {
  final List goodsList;
  const SecondRow({ Key key, this.goodsList }) : super(key: key);


  @override
  Widget build(BuildContext context) {
    return Row(
      children: <Widget>[
        GetGoodsItem(item: this.goodsList[3]),
        GetGoodsItem(item: this.goodsList[4]),
      ],
    );
  }
}

class GetGoodsItem extends StatelessWidget {
  final item;
  const GetGoodsItem({ Key key, this.item }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: () {},
      child: Container(
        width: ScreenUtil().setWidth(355),
        child: Image(image: AssetImage(item['imgUrl'])),
      ),
    );
  }
}